package ${package.Controller};

import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import ${cfg.packageName}.service.${table.serviceName};
import ${cfg.packageName}.entity.${entity};
import ${cfg.packageName}.vo.ResponseModel;
<#if swagger2>
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
</#if>
<#--shiro权限注释-->
<#if cfg.shiro>
import org.apache.shiro.authz.annotation.RequiresPermissions;
import ${cfg.packageName}.annotation.PermInfo;
</#if>
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#--不存在值检测操作符??,这个操作符告诉我们一个值是否存在-->
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>

/**
 * <p>
 * ${table.comment!} 前端控制器
 * </p>
 *
 * @author ${author}
 * @since ${date}
**/
<#if swagger2>
@Api(tags = {"${table.comment!}操作接口"})
</#if>
<#--操作权限注释，采用自定义permInfo注释，包括value（权限描述）和pval（权限值）两个值，均是字符串类型-->
<#--如不需，请手动删除（也请同时删除引用的package-->
<#if cfg.shiro>
@PermInfo(pval = "${table.name?replace("_",":","f")}:*", value = "操作${table.comment!}的权限")
</#if>
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} {
   </#if>
   private static final Logger logger = LoggerFactory.getLogger(${table.controllerName}.class);
   @Autowired
   private ${table.serviceName} ${table.entityPath}Service;

   /**
    * 查询分页数据
    */
   <#if swagger2>
   @ApiOperation(value = "分页查询${table.comment!}数据")
   </#if>
   <#if cfg.shiro>
   @RequiresPermissions({"${table.name?replace("_",":","f")}:list"})
   </#if>
   @GetMapping("/list")
   public ResponseModel findListByPage(@RequestParam(name = "current", defaultValue = "1") int current,
                               @RequestParam(name = "size", defaultValue = "20") int size){
       return null;
   }


   /**
    * 根据id查询
    */
   <#if swagger2>
   @ApiOperation(value = "根据id查询${table.comment!}数据")
   </#if>
   <#if cfg.shiro>
   @RequiresPermissions({"${table.name?replace("_",":","f")}:query"})
   </#if>
   @GetMapping("/getById")
   public ResponseModel getById(@RequestParam("pkid") String pkid){
       return null;
   }

   /**
    * 新增
    */
   <#if swagger2>
   @ApiOperation(value = "新增${table.comment!}数据")
   </#if>
   <#if cfg.shiro>
   @RequiresPermissions({"${table.name?replace("_",":","f")}:add"})
   </#if>
   @PostMapping("/add")
   public ResponseModel add(@RequestBody ${entity} ${entity?uncap_first}){
       return null;
   }

   /**
    * 批量删除
    */
   <#if swagger2>
   @ApiOperation(value = "批量删除${table.comment!}数据")
   </#if>
   <#if cfg.shiro>
   @RequiresPermissions({"${table.name?replace("_",":","f")}:delete"})
   </#if>
   @DeleteMapping("/del")
   public ResponseModel delete(@RequestParam("ids") List<String> ids){
       return null;
   }

   /**
    * 修改
    */
   <#if swagger2>
   @ApiOperation(value = "更新${table.comment!}数据")
   </#if>
   <#if cfg.shiro>
   @RequiresPermissions({"${table.name?replace("_",":","f")}:update"})
   </#if>
   @PutMapping("/update")
   public ResponseModel update(@RequestBody ${entity} ${entity?uncap_first}){
       return null;
   }

}

</#if>